﻿using System.ComponentModel.DataAnnotations;

namespace _06_Snake
{
    internal class Map
    {
        enum Type
        {
            Empty,
            Wall,
        }

        int width;
        int height;
        Type[,] data;

        // 当你创建了有参构造函数时
        // 就会将默认的无参函数覆盖
        public Map(int width, int height)
        {
            this.width = width;
            this.height = height;
            data = new Type[width, height];
        }

        public void Init()
        {
            for (int i = 0; i < height; i++)
            {
                for (int j = 0; j < width; j++)
                {
                    if(i == 0 || j == 0 || i == height - 1 || j == width - 1)
                    {
                        data[i,j] = Type.Wall;
                    }
                }
            }
        }

        public void Input()
        {

        }

        public void Update()
        {

        }

        public void Render()
        {
            for (int i = 0; i < height; i++)
            {
                for (int j = 0; j < width; j++)
                {
                    Console.SetCursorPosition(j, i);
                    switch (data[i, j])
                    {
                        case Type.Empty:
                            break;
                        case Type.Wall:
                            Console.WriteLine("N");
                            break;
                    }
                }
            }
        }

        public void End()
        {

        }
    }
}
